--- title: "L1-003 个位数统计" created: 2025-11-28 tags: - 算法 --- # L1-003 个位数统计 ## 题目 [个位数统计](https://pintia.cn/problem-sets/994805046380707840/exam/problems/type/7?problemSetProblemId=994805143738892288&page=0) ![[image-88e38c83.png]] ## 思路分析 ![[image-dd5ee930.png]] 有坑 直接用数字 %10 /10取每一位会过不了最后一个数据 用longlong也不行 ```cpp #include using namespace std; #define endl '\n' typedef long long ll; int main() { ios::sync_with_stdio(0), cin.tie(0), cout.tie(0); ll n; cin >> n; map cnt; if(n==0){ cout<<"0:1"< using namespace std; #define endl '\n' typedef long long ll; int main() { ios::sync_with_stdio(0), cin.tie(0), cout.tie(0); string s; cin>>s; int cnt[10]={0}; for(char c:s){ int num = c - '0'; cnt[num]++; } for(int i=0;i<10;i++){ if(cnt[i]>0){ cout<